<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>

</head>

<body>
  <div id="app">
    <common-head></common-head>
  </div>
  <script src="./vue.global.js"></script>
  <script>
    const { createApp } = Vue;
    const app = createApp({});
    const CommonChild = {
      template: `
        <div>
          <header>
            子组件头部  
            <slot name="header"></slot>
          </header>
          <main>
            <slot></slot>
          </main>
          <footer>
            子组件底部  
            <slot name="footer"></slot>
          </footer>
        </div>
      `,
      
    }
    const CommonHead = {
      // 模板视图
      template: `
        <div>
          这是父组件
          <hr/>
          <common-child>
            <button>按钮</button>  
            <template v-slot:header>
              <h1>这是传给头部的</h1>
            </template>
            <template #footer>
              <mark>这是传给尾部的</mark>
            </template>
          </common-child>
         
        </div>
      `,
      components: {
        CommonChild
      }
    }
    app.component('CommonHead', CommonHead)

    app.mount('#app')
  </script>
</body>

</html>